<?php

namespace app\admin\controller;

use library\Controller;
use think\Db;

/**
 * 短信验证码
 */
class SmsCode extends Controller
{
    /**
     * 绑定数据表
     * @var string
     */
    protected $table = 'LcSmsCode';

    /**
     * 短信验证码管理
     * @auth true
     * @menu true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '短信验证码管理';
        $query = $this->_query($this->table)->like('phone');
        $query->order('id desc')->page();
    }

    /**
     * 添加
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function add()
    {
        $this->title = '添加短信验证码';
        $this->_form($this->table, 'form');
    }

    /**
     * 删除会员组
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function remove()
    {
        $this->applyCsrfToken();
        $this->_delete($this->table);
    }

    protected function _form_filter(&$vo){
        if (empty($vo['time'])) $vo['time'] = date("Y-m-d H:i:s");
    }
}
